
/*code data for latino participants*/

/*code and drop non-latinos*/

gen latino=0
recode latino(0=1) if Q1==3
tab latino

drop if latino==0

/*treatments*/

gen foreigner=0
recode foreigner(0=1) if m1==2

tab foreigner

/*outcomes*/

**solidarity with PoC

gen pocsolid1=Q21
gen pocsolid=(pocsolid1-1)/4
summ pocsolid

gen pocsolid2=(Q22)
recode pocsolid2(1=5)(2=4)(3=3)(4=2)(5=1)
gen pocsolids=(pocsolid2-1)/4

summ pocsolid pocsolids
alpha pocsolid pocsolids, std
pwcorr pocsolid pocsolids, sig

gen pocsolidscale=(pocsolid+pocsolids)/2
summ pocsolidscale

**legal immigration

gen supportH1B1=Q24
gen supportH1B=(supportH1B1-1)/4
summ supportH1B

gen legalimg1=Q25
gen legalimg=(legalimg1-1)/4
summ legalimg

gen legalpol=(supportH1B+legalimg)/2
summ legalpol

**undocumented immigration

gen bpatrol1=Q26
recode bpatrol1(1=5)(2=4)(3=3)(4=2)(5=1)
gen bpatrol=(bpatrol1-1)/4
summ bpatrol

gen pathway1=Q27
gen pathway=(pathway1-1)/4
summ pathway

gen undocpol=(bpatrol+pathway)/2
summ undocpol


/*drop folks who fail manipulation check*/

tab Q19
drop if Q19==2

***N=624 - dropped = sample analyzed
***for analysis of full sample, keep those who failed manipulation check


/*inter-item correlations in sample under analysis*/

polychoric pocsolid pocsolids
polychoric supportH1B legalimg
polychoric bpatrol pathway

/*does treatment affect outcomes*/

reg undocpol foreigner
reg legalpol foreigner

ttest legalpol, by(foreigner)

/*does treatment affect our mediator*/

reg pocsolidscale foreigner
ttest pocsolidscale, by(foreigner)

/*do shifts in the mediator affect our outcomes*/

reg legalpol pocsolidscale
reg undocpol pocsolidscale

***results for table 2

**per Reviewer 2, original results were adjusted for liberal ideology

*table 2

gen liberal1=Q13
gen liberal=(liberal1-1)/6
summ liberal

pwcorr pocsolidscale liberal, sig

reg undocpol foreign 
reg pocsolidscale foreigner
reg undocpol pocsolidscale foreign liberal

reg legalpol foreign 
reg pocsolidscale foreigner 
reg legalpol pocsolidscale foreign liberal

***results for table SI.4

***rescale supportH1B1 to 0-1

gen supportHIGH=(supportH1B1-1)/4
summ supportHIGH

reg pocsolid foreigner
reg pocsolids foreigner

reg pathway pocsolid
reg pathway pocsolids

reg bpatrol pocsolid
reg bpatrol pocsolids

reg supportHIGH pocsolid
reg supportHIGH pocsolids

reg legalimg pocsolid
reg legalimg pocsolids

***estimate ACMEs, with liberal ideology as covariate

medeff (regress pocsolidscale foreign)(regress undocpol foreign pocsolidscale liberal), mediate(pocsolidscale) treat(foreign) sims(500) seed(1)
medeff (regress pocsolidscale foreign)(regress legalpol foreign pocsolidscale liberal), mediate(pocsolidscale) treat(foreign) sims(500) seed(1)

***sensitivity analyses

medsens (regress pocsolidscale foreigner) (regress undocpol foreigner pocsolidscale liberal), mediate(pocsolidscale) treat(foreigner) sims(1000) eps(.01) graph level(95)
medsens (regress pocsolidscale foreigner) (regress legalpol foreigner pocsolidscale liberal), mediate(pocsolidscale) treat(foreigner) sims(1000) eps(.01) graph level(95)

***quantities for figure 4 are calculated by hand using the relevant regressions above where policy support is influenced by solidarity

***table SI.4 (be sure taht failed manipulation checks are excluded)

reg pocsolid foreigner
reg pocsolids foreigner

reg pathway pocsolid
reg pathway pocsolids
reg bpatrol pocsolid
reg bpatrol pocsolids
reg supportHIGH pocsolid
reg supportHIGH pocsolids
reg legalimg pocsolid
reg legalimg pocsolids
